<template>
  <div>
    <publicPageVue v-if="Object.keys(pageSetting).length > 0" :json-obj="pageSetting" name="UserList" :tables="tables" />
  </div>
</template>
<script>
  import { translateTitle } from '@/utils/i18n'
  import { Mixin } from '@/common/minxin/Mixin'
  import { GFCD } from '@/utils/utils'
  import { getList } from '../../api/home'
  import publicPageVue from '../../components/publicPage.vue'
  import UserList from '../../components/json/UserList'
  export default {
    name: 'UserList',
    components: { publicPageVue },
    mixins: [Mixin],
    data() {
      return {
        tables: {
          tableList: [],
          count: 0,
          pageSize: 50,
          limit: 1,
          name: 'UserList',
          operation: false,
          isNew: true,
          btns: [
            { name: translateTitle('Dams.ApplicationInterface.启用'), key: 'startUsing' },
            // { name: '启用', key: 'startUsing' },
            { name: translateTitle('Dams.ApplicationInterface.密码重置'), key: 'pswReset' },
            { name: translateTitle('Dams.ApplicationInterface.密码修改'), key: 'pswAmend' },
          ],
          width: '350',
        },
        pageSetting: {},
        configSetting: {},
      }
    },
    created() {
      this.init()
    },
    methods: {
      translateTitle,
      async init() {
        this.configSetting = GFCD('dams')
        let res = await this.getApp()
        let res1 = await this.getOrganization()
        let list = []
        let list1 = []
        res.forEach((row) => {
          list.push({ LABEL: row.APP_NAME, CODE: row.ID })
        })
        res1.forEach((row) => {
          list1.push({ LABEL: row.NAME, CODE: row.ORG_ID })
        })
        // this.nowJsonData().then((data) => {
        //   console.log('data', data)
        UserList.UserList.dialog.form.field.forEach((row) => {
          if (row.name == 'ORGIDS') {
            row.options = list1
          }
          if (row.name == 'APPS') {
            row.options = list
          }
        })
        this.pageSetting = UserList
        // })
      },
      async getApp() {
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          data: JSON.stringify({ '#LIMIT#': 1, '#PAGE_SIZE#': 9999 }),
          method: 'sysAppServiceImpl.queryTable',
        })
        return res.data['sysAppServiceImpl.queryTable'].data
      },
      async getOrganization() {
        let res = await getList(`${this.configSetting.domain}${this.configSetting.baseUrl}`, {
          data: JSON.stringify({ '#LIMIT#': 1, '#PAGE_SIZE#': 9999 }),
          method: 'sysOrganizationServiceImpl.queryTable',
        })
        return res.data['sysOrganizationServiceImpl.queryTable'].data
      },
    },
  }
</script>
